<?php
function databaseToSortingTable($lineCurve,$name,$title){
		$resultContent="";
		$row = mysql_fetch_assoc($lineCurve);
				$resulthead="<thead>
									<tr>";
				$resultfoot=   "</tbody>
										<tfoot>
											<tr>";
				foreach($row as $name => $value) {
				$resulthead .="<th>$name</th>";
				$resultfoot .="<th>$name</th>";
				}
				$resulthead  .="	</tr>
										</thead>
											<tbody>";
				$resultfoot .="	 </tr>
											</tfoot>
										</table></div>";
while($row) {
	$resultContent .="<tr class='gradeC'>";
	foreach($row as $value) {
		$resultContent .="<td>$value</td>";
	}
	$resultContent .="</tr>";
	$row = mysql_fetch_assoc($lineCurve);
}
				
			$script="
		<style type='text/css' title='currentStyle'>
			@import 'css/demo_page.css';
			@import 'css/demo_table.css';
		</style>
		<script type='text/javascript' language='javascript' src='js/jquery.js'></script>
		<script type='text/javascript' language='javascript' src='js/jquery.dataTables.js'></script>
		<script type='text/javascript' charset='utf-8'>
			$(document).ready(function() {
				$('#$name').dataTable();
			} );
		</script>
			<div class='tableBackground'>
			<strong>$title</strong><br>
		<table cellpadding='0' cellspacing='0' border='0' class='display' id='".$name."' width='100%'>";
		return $script.$resulthead.$resultContent.$resultfoot;
	
}

function databaseToTable($lineCurve,$option){
	switch ($option) {
		case '_s_report_monthyear_by_org':
	    case '_s_report_daterange_by_org':
			$name="name1";
			$title="销售时段/商铺报告";
			$firstTitle="商铺";
			$firstName="organization";
			break;
		case '_s_report_monthyear_by_productcode':
	    case '_s_report_daterange_by_productcode':
			$name="name1";
			$title="销售时段/产品报告";
			$firstTitle="款号";
			$firstName="product_code";
			break;
		case '_s_report_monthyear_by_scancode':
	    case '_s_report_daterange_by_scancode':
			$name="name1";
			$title="销售时段/扫描条码报告";
			$firstTitle="扫描条码";
			$firstName="scan_code";
			break;
		default:
			return 0;
			break;
				}
			$resulthead="<thead>
							<tr>
								<th>$firstTitle</th>
								<th>退款总额</th>
								<th>收入金额</th>
								<th>净收入</th>
								<th>退款总件数</th>
						        <th>售出总件数</th>
								<th>净件数</th>
							</tr>
						</thead>
						<tbody>";
						$resultfoot=	"
								</tbody>
									<tfoot>
									  <tr>
										<th>商铺</th>
										<th>退款总额</th>
										<th>收入金额</th>
										<th>净收入</th>
	            						<th>退款总件数</th>
								        <th>售出总件数</th>
										<th>净件数</th>
									   </tr>
									</tfoot>
								</table></div>";
			     $resultContent="";
				while($row = mysql_fetch_array($lineCurve)){
				      				$first=$row[$firstName];
									$return_amount=$row['return_amount'];
									$sell_amount=$row['sell_amount'];
									$sale_amount=$row['sale_amount'];
									$return_number=$row['return_number'];
									$sell_number=$row['sell_number'];
									$sale_number=$row['sale_number'];
									
						      		$resultContent.="
						<tr class='gradeC'>
							<td>$first</td>
							<td>$return_amount</td>
							<td>$sell_amount</td>
							<td>$sale_amount</td>
							<td>$return_number</td>
							<td>$sell_number</td>
							<td>$sale_number</td>
						</tr>";
				}
				
			$script="
		<style type='text/css' title='currentStyle'>
			@import 'css/demo_page.css';
			@import 'css/demo_table.css';
		</style>
		<script type='text/javascript' language='javascript' src='js/jquery.js'></script>
		<script type='text/javascript' language='javascript' src='js/jquery.dataTables.js'></script>
		<script type='text/javascript' charset='utf-8'>
			$(document).ready(function() {
				$('#$name').dataTable();
			} );
		</script>
			<div class='tableBackground'>
			<strong>$title</strong><br>
		<table cellpadding='0' cellspacing='0' border='0' class='display' id='".$name."' width='100%'>";
		return $script.$resulthead.$resultContent.$resultfoot;
		
			
}
function organizatonsToTable($organizations){
	global $itemTopSize;
			global $itemSize;
			global $itemColor;
			global $itemMaterial;
			global $itemSeason;
			global $itemYear;
			global $itemType;
			global $itemDesigner;
			global $organizationType;
	$result="<style type='text/css' title='currentStyle'>
					@import 'css/demo_page.css';
					@import 'css/demo_table.css';
				</style>
				<script type='text/javascript' language='javascript' src='js/jquery.js'></script>
				<script type='text/javascript' language='javascript' src='js/jquery.dataTables.js'></script>
				<script type='text/javascript' charset='utf-8'>
					$(document).ready(function() {
						$('#organizations').dataTable();
					} );
				</script>
					<div class='tableBackground'>
					<strong>所有机构列表</strong><br>
			<table cellpadding='0' cellspacing='0' border='0' class='display' id='organizations' width='100%'>";
		
	
		$resulthead="<thead>
			<tr>
		    	<td>机构号</td>
				<td>名字</td>
				<td>类型</td>
				<td>描述</td>
				<td>操作</td>
			</tr>
		</thead>
	<tbody>";
	
		$resultfoot=	"
		</tbody>
			<tfoot>
			  <tr>
			  	<th>机构号</th>
				<th>名字</th>
				<th>类型</th>
				<th>描述</th>
				<th>操作</th>
			   </tr>
			</tfoot>
		</table></div>";
		$resultContent="";
	$grade='gradeC';
	foreach($organizations as $org){
			$id=$org->id;
			$name=$org->name;
			$type=$organizationType[$org->type];
			$des=$org->des;
			$form="<form action='api/' method='post'>
	        	<input type='hidden' id='action' name='action' value='delete_organization' />
	            <input type='hidden' id='id' name='id' value='".$id."' />
	
	            <input type='submit' value='删除' />
	          </form>
	          
	          
	          <form action='index.php' method='GET'>
	          	            <input type='hidden' id='id' name='id' value='".$id."'/>
	          	            <input type='hidden' id='page' name='page' value='alter_organizations'/>
	
				<div>
				<input type='submit' value='更改'>
				</div>
			  </form>";
			
		    	$grade='gradeC';
		  
		   
			$resultContent.="
			<tr class='$grade'>
				
				<td class='center'>$id</td>
				<td>$name</td>
				<td>$type</td>
				<td>$des</td>
				<td>$form</td>
				
			</tr>";
			

	
			
		}
		return $result.$resulthead.$resultContent.$resultfoot;
		
	}
function inventoryToTable($inventory,$name,$title,$option){
			global $itemTopSize;
			global $itemSize;
			global $itemColor;
			global $itemMaterial;
			global $itemSeason;
			global $itemSeason4;
			global $itemYear;
			global $itemType;
			global $itemDesigner;
			global $organizationType;
			
		$name=$name.'Table';
	
		$result="<style type='text/css' title='currentStyle'>
					@import 'css/demo_page.css';
					@import 'css/demo_table.css';
				</style>
				<script type='text/javascript' language='javascript' src='js/jquery.js'></script>
				<script type='text/javascript' language='javascript' src='js/jquery.dataTables.js'></script>
				<script type='text/javascript' charset='utf-8'>
					$(document).ready(function() {
						$('#$name').dataTable();
					} );
				</script>
					<div class='tableBackground'>
					<strong>$title 库存详情表</strong><br>
			<table cellpadding='0' cellspacing='0' border='0' class='display' id='".$name."' width='100%'>";
			$extraName="";
		if($option=="radio"){//inv_id
			$extraName='<th>选择</th>';
		}elseif($option=="total"){
			$extraName='<th>机构名</th>';
		}
		$resulthead="<thead>
			<tr>
		    $extraName
			<th>数量</th>
			<th>扫描条码</th>
			<th>生产款号</th>
			<th>设计版号</th>
			<th>类型</th>
	        <th>年份</th>
			<th>季节</th>
			<th>流水号</th>
			<th>面料</th>
			<th>色彩</th>
			<th>尺寸</th>
	        <th>设计师</th>
			<th>原价</th>
			<th>折率</th>
			<th>现售与否</th>
			<th>产品名</th>
		</tr>
	</thead>
	<tbody>";
	
	$resultfoot=	"
	</tbody>
		<tfoot>
		  <tr>
		  	$extraName
			<th>数量</th>
			<th>扫描条码</th>
			<th>生产款号</th>
			<th>设计版号</th>
			<th>类型</th>
	        <th>年份</th>
			<th>季节</th>
			<th>流水号</th>
			<th>面料</th>
			<th>色彩</th>
			<th>尺寸</th>
	        <th>设计师</th>
			<th>原价</th>
			<th>折率</th>
			<th>现售与否</th>
			<th>产品名</th>
		   </tr>
		</tfoot>
	</table></div>";
	
	$resultContent="";
	$label='odd';
	$grade='gradeC';
	foreach($inventory as $inv){
		
			$id=$inv['id'];
			$number=$inv['number'];
			$scan_code=$inv['item']->scan_code;
			$product_code=$inv['item']->product_code;
			$designer_code=$inv['item']->designer_code;
			$type=$itemType[$inv['item']->type];
			$year=$itemYear[$inv['item']->year];
			$season=$itemSeason[$inv['item']->season];
		 if(strlen($scan_code)==14){ 			$season=$itemSeason[$inv['item']->season];
}else{			$season=$itemSeason4[$inv['item']->season];
}
           
			$flow=$inv['item']->flow;
			$material=$itemMaterial[$inv['item']->material];
			$size=$itemSize[$inv['item']->size];
			$color=$itemColor[$inv['item']->color];
			$designer=$itemDesigner[$inv['item']->designer];
			$extraColumn="";
			if($option=="radio"){
				$extraColumn="<td><input type='radio' name='inv_id' value='$id' ></input></td>";	
			}elseif($option=="total"){
		$extraColumn='<td>'.$inv['name'].'</td>';
	       }
			$price=$inv['item']->price;
			$ratio=$inv['item']->ratio."%";
			$active=($inv['item']->active==1) ? '是' : '否';
		    $name=$inv['item']->name;
		    $grade="";
		    if($inv['item']->active!=1){
		 	 	$grade='gradeU';
		    }elseif($ratio!='100%'){
		    	$grade='gradeX';
		    }else{
		    	$grade='gradeC';
		    }
		   
			$resultContent.="
			<tr class='$grade'>
				$extraColumn
				<td>$number</td>
				<td>$scan_code</td>
				<td>$product_code</td>
				<td>$designer_code</td>
				<td>$type</td>
				<td>$year</td>
				<td>$season</td>
				<td>$flow</td>
				<td>$material</td>
				<td>$color</td>
				<td>$size</td>
				<td>$designer</td>
				<td>$price</td>	
				<td>$ratio</td>	
				<td>$active</td>	
				<td>$name</td>
			</tr>";
			
			
		}
		return $result.$resulthead.$resultContent.$resultfoot;
	
}

function financialTransactionToTable($transaction,$name,$title){
			global $organizationType;
			global $actionType;
			global $confirmType; 
	$name=$name.'TTable';
	$extraName=""; 
		$title=$title." 交易";
		 $soldNum=0;
		 $returnNum=0;
		 $netNum=0;
		 $soldAmount=0;
		 $returnAmount=0;
		 $netAmount=0;
		

	$result="<style type='text/css' title='currentStyle'>
			@import 'css/demo_page.css';
			@import 'css/demo_table.css';
		</style>
		<script type='text/javascript' language='javascript' src='js/jquery.js'></script>
		<script type='text/javascript' language='javascript' src='js/jquery.dataTables.js'></script>
<script type='text/javascript' charset='utf-8'>
			$(document).ready(function() {
				$('#$name').dataTable();
			} );
		</script>
			<div class='tableBackground'>
			<strong>$title 详情表</strong><br>
	<table cellpadding='0' cellspacing='0' border='0' class='display' id='".$name."' width='100%'>";
	
	$resulthead="<thead>
		<tr>
		    $extraName
		<th>记录号</th>
		<th>种类</th>
		<th>来自</th>
		<th>状态</th>
        <th>受理人</th>
		<th>扫描条码</th>
		<th>金额</th>
		<th>数目</th>
		<th>收据号码</th>
		<th>交易时间</th>
		</tr>
	</thead>
	<tbody>";
	
	$resultfoot=	"
	</tbody>
		<tfoot>
		  <tr>
		  	$extraName
				<th>记录号</th>
		<th>种类</th>
		<th>来自</th>
		<th>状态</th>
        <th>受理人</th>
		<th>扫描条码</th>
		<th>金额</th>
		<th>数目</th>
		<th>收据号码</th>
		<th>交易时间</th>
		   </tr>
		</tfoot>
	</table>
	</div>
	
	
	";
	
	$resultContent="";
	$grade='gradeC';
	
	
	foreach($transaction as $trans){
		$id=$trans->id;
		$action=$actionType[$trans->action];
    	$source=$trans->source;
    	$target=$trans->target;
    	$confirm=$trans->confirm;
    	$confirmName=$confirmType[$confirm];
    	$user1=$trans->user1;
    	$user2=$trans->user2;
    	$code=$trans->code;
    	if($option=='checkbox'){
    		$user2="无";
    	}
	    $scan_code=$trans->scan_code;
    	$amount=$trans->amount;
    	$income=$trans->income;
	    $begin_time_stamp=$trans->begin_time_stamp;
	    $finish_time_stamp=$trans->finish_time_stamp;
	    $mark=""; $grade="";$mark1="";
			 if($trans->action=="sell"){
			 
					 $soldNum=$soldNum+$amount;
					 $netNum=$netNum+$amount;
					 $soldAmount=$soldAmount+$income;
					 $netAmount=$netAmount+$income;
			 
                 $mark="-";
                 $mark1="+";
                 $grade='gradeA';
			 }elseif($trans->action=="return"){
			 	
			 	$returnNum=$returnNum+$amount;
		  		$netNum=$netNum-$amount;
				$returnAmount=$returnAmount+$income;
				$netAmount=$netAmount-$income;
				
			 
			 	$mark="+";
			 	$mark1="-";
			 	$grade='gradeX';
			 }elseif($trans->action=="consume"){
			 	$mark="";
			 	$mark1="";
			 	$grade='gradeU';
			 }else{
			 	$mark="";
			 	$mark1="";
			 	$grade='gradeB';
			 	
			 }
	   
	   		$money="";$extraColumn="";
			
	
			
			
			$resultContent.="
		         <tr class='$grade'>
					$extraColumn	
					<td>$id</td>
					<td>$action</td>
					<td>$source</td>
					<td>$confirmName</td>
					<td>$user1</td>
					<td>$scan_code</td>
					<td>$mark1$income</td>
					<td>$mark$amount</td>
					<td>$code</td>
					<td>$begin_time_stamp</td>
				</tr>";
			
			
		}


	$resultfoot.='<br><br><table>
	<thead/>
	<tr>
	    <th>总售出件数</th>
		<th>总退还件数</th>
		<th>净售出件数</th>
		<th>总出售额</th>
		<th>总退款额</th>
		<th>净退款额</th>
		</tr>
	</thead>
	<tbody>
		<td>'.$soldNum.'</td>
		<td>'.$returnNum.'</td>
		<td>'.$netNum.'</td>
		<td>'.$soldAmount.'</td>
		<td>'.$returnAmount.'</td>
		<td>'.$netAmount.'</td>
	</tbody>
	</table>';



		return $result.$resulthead.$resultContent.$resultfoot;
	
}




function transactionToTable($transaction,$name,$title,$option){
			global $itemTopSize;
			global $itemSize;
			global $itemColor;
			global $itemMaterial;
			global $itemSeason;
			global $itemYear;
			global $itemType;
			global $itemDesigner;
			global $organizationType;
			global $actionType;
			global $confirmType; 
	$name=$name.'TTable';
	$extraName=""; $finance="";
	if($option=="radio"){//inv_id
		$extraName='<th>选择</th>';
	}elseif($option=="stack"){//inv_id
		$extraName='<th>操作</th>';
	}elseif($option==NULL){
		//echo $option;
		$title=$title." 物流";
	   
	}elseif($option=='finance'){
		$title=$title." 交易";
		 $finance="<th>金额</th>";
		 $soldNum=0;
		 $returnNum=0;
		 $netNum=0;
		 $soldAmount=0;
		 $returnAmount=0;
		 $netAmount=0;
		
	}elseif($option=='checkbox'){
		$title=$title." 待定";
	   $extraName='<th>选择</th>';
	}
	$result="<style type='text/css' title='currentStyle'>
			@import 'css/demo_page.css';
			@import 'css/demo_table.css';
		</style>
		<script type='text/javascript' language='javascript' src='js/jquery.js'></script>
		<script type='text/javascript' language='javascript' src='js/jquery.dataTables.js'></script>
<script type='text/javascript' charset='utf-8'>
			$(document).ready(function() {
				$('#$name').dataTable();
			} );
		</script>
			<div class='tableBackground'>
			<strong>$title 详情表</strong><br>
	<table cellpadding='0' cellspacing='0' border='0' class='display' id='".$name."' width='100%'>";
	
	$resulthead="<thead>
		<tr>
		    $extraName
		<th>记录号</th>
		<th>种类</th>
		<th>来自</th>
		<th>目标</th>
		<th>状态</th>
        <th>发起用户</th>
        ";
		if(!$option=="stack"){
		$resulthead.="<th>确认用户</th>";
		}
		$resulthead.="
		<th>扫描条码</th>
		$finance
		<th>数目</th>
		<th>发起时间</th>
		<th>结束时间</th>
		</tr>
	</thead>
	<tbody>";
	
	$resultfoot=	"
	</tbody>
		<tfoot>
		  <tr>
		  	$extraName
				<th>记录号</th>
		<th>种类</th>
		<th>来自</th>
		<th>目标</th>
		<th>状态</th>
        <th>发起用户</th>
";
		if(!$option=="stack"){
		$resultfoot.="<th>确认用户</th>";
		}
		$resultfoot.="
		<th>扫描条码</th>
		$finance
		<th>数目</th>
		<th>发起时间</th>
		<th>结束时间</th>
		   </tr>
		</tfoot>
	</table>
	</div>
	
	
	";
	
	$resultContent="";
	$grade='gradeC';
	
	
	foreach($transaction as $trans){
		$id=$trans->id;
		$action=$actionType[$trans->action];
    	$source=$trans->source;
    	$target=$trans->target;
    	$confirm=$trans->confirm;
    	$confirmName=$confirmType[$confirm];
    	$user1=$trans->user1;
    	$user2=$trans->user2;
		if($user2=="customer"){
			$user2="--";
		}
    	if($option=='checkbox'){
    		$user2="无";
    	}
	    $scan_code=$trans->scan_code;
    	$amount=$trans->amount;
    	$income=$trans->income;
	   $begin_time_stamp=$trans->begin_time_stamp;
	   $finish_time_stamp=$trans->finish_time_stamp;
	   $mark=""; $grade="";$mark1="";
			 if($trans->action=="sell"){
			 	 if($option=='finance'){
					 $soldNum=$soldNum+$amount;
					 $netNum=$netNum+$amount;
					 $soldAmount=$soldAmount+$income;
					 $netAmount=$netAmount+$income;
			    }
                 $mark="-";
                 $mark1="+";
                 $grade='gradeA';
			 }elseif($trans->action=="return"){
			 	 if($option=='finance'){
			 	$returnNum=$returnNum+$amount;
		  		$netNum=$netNum-$amount;
				$returnAmount=$returnAmount+$income;
				$netAmount=$netAmount-$income;
				
			    }
			 	$mark="+";
			 	$mark1="-";
			 	$grade='gradeX';
			 }elseif($trans->action=="consume"){
			 	$mark="";
			 	$mark1="";
			 	$grade='gradeU';
			 }else{
			 	$mark="";
			 	$mark1="";
			 	$grade='gradeB';
			 	
			 }
	   
	   		$money="";$extraColumn="";
			
	   		if($option=='finance'){
	   			//echo "finance";
				$money="<td>$mark1$income</td>";
			}elseif($option=="radio"){
				//echo "radio";
				$extraColumn="<td><input type='radio' name='tran_id' value='$id' checked></input></td>";	
				
			}elseif($option=="stack"){
				$extraColumn="<td class=' '><div class='button blue' onclick='del(\"$id\")'>删除</div><div class='button blue' onclick='alter(\"$id\")'>更改数目</div></td>";	
				
			}elseif($option=="checkbox"){
								//echo "checkbox";
				
				$extraColumn="<td><input type='checkbox' name='tran_id[]' value='$id'></td>";	
			}
			$resultContent.="
		         <tr class='$grade'>
					$extraColumn	
					<td>$id</td>
					<td>$action</td>
					<td>$source</td>
					<td>$target</td>
					<td>$confirmName</td>
					<td>$user1</td>
";
		if(!$option=="stack"){
		$resultContent.="<th>$user2</th>";
		}
		$resultContent.="					<td>$scan_code</td>
					$money
					<td>$mark$amount</td>
					<td>$begin_time_stamp</td>
					<td>$finish_time_stamp</td>
				</tr>";
			
			
		}

if($option=='finance'){
	$resultfoot.='<br><br><table>
	<thead/>
	<tr>
	    <th>总售出件数</th>
		<th>总退还件数</th>
		<th>净售出件数</th>
		<th>总出售额</th>
		<th>总退款额</th>
		<th>净退款额</th>
		</tr>
	</thead>
	<tbody>
		<td>'.$soldNum.'</td>
		<td>'.$returnNum.'</td>
		<td>'.$netNum.'</td>
		<td>'.$soldAmount.'</td>
		<td>'.$returnAmount.'</td>
		<td>'.$netAmount.'</td>
	</tbody>
	</table>';

}

		return $result.$resulthead.$resultContent.$resultfoot;
	
}
function itemToTable($item,$name,$title,$option){
			global $itemTopSize;
			global $itemSize;
			global $itemColor;
			global $itemMaterial;
			global $itemSeason;
			global $itemSeason4;
			global $itemYear;
			global $itemType;
			global $itemDesigner;
			global $organizationType;
			global $actionType;
			global $confirmType;
			
		

			$name=$name.'ITable';
			$extraName=""; $finance="";
			if($option=="radio"){//inv_id
				$title="产品列表";
			   $extraName='<th>操作</th>';
			}elseif($option==NULL){
				$title=$title." 物流";
				
			}elseif($option=='checkbox'){
				$extraName='<th>选择</th>';
				
			}elseif($option=='button'||$option=='button1'){
				$extraName='<th>操作</th>';
				
			}
			$result="
				<style type='text/css' title='currentStyle'>
					@import 'css/demo_page.css';
					@import 'css/demo_table.css';
				</style>
				<script type='text/javascript' language='javascript' src='js/jquery.dataTables.js'></script>
				<script type='text/javascript' charset='utf-8'>
					$(document).ready(function() {
						$('#$name').dataTable();
					} );
				</script>
				<div class='tableBackground'>
				<strong>$title</strong><br>
				<table cellpadding='0' cellspacing='0' border='0' class='display' id='".$name."' width='100%'>";
	
			$resulthead="<thead>
				<tr>
		      	$extraName
				<th>扫描条码</th>
				<th>生产款号</th>
				<th>设计版号</th>
				<th>类型</th>
		        <th>年份</th>
				<th>季节</th>
				<th>流水号</th>
				<th>面料</th>
				<th>色彩</th>
				<th>尺寸</th>
				<th>设计师</th>
				<th>原价</th>
				<th>折率</th>
				<th>现售与否</th>
				<th>产品名</th>
				   
				</tr>
			</thead>
			<tbody>";
			
			$resultfoot=	"
			</tbody>
				<tfoot>
				  <tr>
				  $extraName
					<th>扫描条码</th>
					<th>生产款号</th>
					<th>设计版号</th>
					<th>类型</th>
			        <th>年份</th>
					<th>季节</th>
					<th>流水号</th>
					<th>面料</th>
					<th>色彩</th>
					<th>尺寸</th>
					<th>设计师</th>
					<th>原价</th>
					<th>折率</th>
					<th>现售与否</th>
					<th>产品名</th>
				   
				   </tr>
				</tfoot>
			</table>
			</div>
			
			
			";
			$resultContent="";
			$grade='gradeC';
			
			
			foreach($item as $i){
					
		
		
		
			$scan_code=$i->scan_code;
			if($option=="radio"){//inv_id
			  $extraColumn="<input type='radio' name='scan_code' value='$scan_code' checked>";
	        }elseif($option=="checkbox"){
	         $extraColumn="<input type='radio'' name='scan_code' value='$scan_code' checked>";
	        }elseif($option=="button"){
	         $extraColumn="
		 <form action='index.php' method='GET'>
          	            <input type='hidden' id='scan_code' name='scan_code' value='$scan_code' />
          	            <input type='hidden' id='page' name='page' value='alter_item'/>
				<div>
						<input type='submit' value='更改'>
						</div>
		</form>";
	        		
	        	
	        
			}elseif($option=="button1"){
	         $extraColumn="<div class='button blue' onclick='addPlan(\"$scan_code\")'>入库</div>";
	        		
	        	
	        
			}else{
	          $extraColumn="";
	        }
	 		$product_code=$i->product_code;
	 		$designer_code=$i->designer_code;
	 		$type=$itemType[$i->type];
	 		$year=$itemYear[$i->year];
	 		if(strlen($scan_code)==14){$season=$itemSeason[$i->season];}else{$season=$itemSeason4[$i->season];}
            
	 		$flow=$i->flow;
			$material=$itemMaterial[$i->material];
			$color=$itemColor[$i->color];
			$size=$itemSize[$i->size];
			$design=$itemDesigner[$i->designer];
			$price=$i->price;
			$ratio=$i->ratio.'%';
			$active=($i->active==1) ? '是' : '否';
			$name=$i->name;
				
			if($i->active!=1){
		 	 	$grade='gradeU';
		    }elseif($ratio!='100%'){
		    	$grade='gradeX';
		    }else{
		    	$grade='gradeC';
		    }
		
	   		
		   
		 
			$resultContent.="
		 		<tr class='$grade'>
					<td>$extraColumn</td>
					<td>$scan_code</td>
					<td>$product_code</td>
					<td>$designer_code</td>
					<td>$type</td>
					<td>$year</td>
					<td>$season</td>
					<td>$flow</td>
					<td>$material</td>
					<td>$color</td>
					<td>$size</td>
					<td>$design</td>	
					<td>$price</td>	
					<td>$ratio</td>	
					<td>$active</td>	
					<td>$name</td>
				</tr>";
			
			
		}
 		return $result.$resulthead.$resultContent.$resultfoot;



	}

	
?>